home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 July
/
EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso
/
earcd
/
text
/
hyper
/
ixg07db.lha
/
ixg07db
/
docs
/
n&c.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-04-12
|
3KB
|
146 lines
/*
** Sample arexx program for iX-Guide
** This is Naughts & Crosses game which you can include
** into your document and play it.
** This is just an example of what can be done with
** iX-Guide AREXX which still needs to be improved a lot.
*/
if ~show('l', "rexxsupport.library") then
addlib('rexxsupport.library',0,-30,0)
OPTIONS RESULTS
/*
** Every rexx client receives pointer to iXG window as the last argument
** in form 'iXW=<address>'. That is the window the rexx client was launched
** from. You always have to pass this pointer to ADDCLIENT !
**
** We will also receive dimensions of draw area
*/
PARSE ARG dimx dimy 'iXW=' windowPTR .
/*
** Port name of every rexx client should be in the following form:
** "IXCL_anythingyouwant_windowPTR"
*/
portname = "IXCL_n&c_"
portname = INSERT(windowPTR,portname,LENGTH(portname))
/************************************************************************/
if show('p',portname) then exit /* we are already running */
ADDRESS IXGUIDE
/*
** Add this client to iX-Guide and pass received window pointer
*/
AddClient windowPTR
/************************************************************************/
EMPTY = 0
NAUGHT = 1
CROSS = 2
board = EMPTY /* this is our board variable */
fw = dimx % 3 /* field dimensions */
fh = dimy % 3
call openport(portname) /* open our message port */
setport portname MOUSE MISC /* we want to receive mouse and misc events */
AllocRaster 1 /* allocate stuff for first rectangle object in our document */
rp=result /* this is the pointer to rastport for our graphics operations */
AutoRefresh rp OFF
call InitBoard() /* initialize the board */
call DrawBoard() /* Draw everything */
shutdown=0
do until shutdown
call waitpkt(portname)
msg = getpkt(portname)
if msg ~= '0000 0000'x then
do
win = getarg(msg)
if win='0000 0000'x then shutdown=1 /* pointer to window is NULL */
else if win=windowPTR then /* this is message from our window */
do
cmd = getarg(msg,1)
if cmd = 'MISC' then
do
a2 = getarg(msg,2)
if a2 = 'CLOSEWIN' then shutdown=1
end
end
call reply(msg,0)
end
end
/*
** End of program
*/
call CleanUp()
exit
/*
** Support functions
*/
InitBoard:
do j=1 to 3
do i=1 to 3
board.i.j = EMPTY
end
end
return 0
DrawField:
arg x,y,kind
xpos = x
ypos = y
SetABPen rp 1
if kind=NAUGHT then
DrawEllipse rp xpos+15 ypos+15 15 15
if kind=CROSS then
do
Move rp xpos ypos
Draw rp xpos+15 ypos+15
end
if kind=EMPTY then
do
SetABPen rp 0
RectFill rp xpos ypos 15 15
end
return 0
DrawBoard:
do j = 0 to 2
do i = 0 to 2
SetABPen rp 1
Move rp i*fw j*fh+fh-1
Draw rp i*fw j*fh
Draw rp i*fw+fw-1 j*fh
SetABPen rp 2
Draw rp i*fw+fw-1 j*fh+fh-1
Draw rp i*fw j*fh+fh-1
end
end
Refresh rp
/* call DrawField(5,10,NAUGHT)*/
return 0
CleanUp:
FreeRaster rp
RemClient
call closeport(portname)
return 0